// app.js
App({
  onLaunch() {
    // 展示本地存储能力
    // const logs = wx.getStorageSync('logs') || []
    // logs.unshift(Date.now())
    // wx.setStorageSync('logs', logs)
    // 登录
    wx.login({
      timeout: 3000,
      success(res) {
        //         console.log(res);
        if (res.code) {
          wx.request({
            url: 'https://api.it120.cc/wangyaole/user/wxapp/authorize',
            method: "POST",
            data: {
              code: res.code,
              //  appid: "wx2496af6ad4458ac6",
              // appsecret: "80e8dc7db8e4e7cff06a45eb06aa603e"
            },
            header: {
              'content-type': 'application/x-www-form-urlencoded'
            },
            success: function (res) {
              // console.log(res.data);
              if (res.data.code == 0) {
                wx.setStorageSync('uid', res.data.data.uid)
                wx.setStorageSync('token', res.data.data.token)
                wx.setStorageSync('openid', res.data.data.openid)
              }
            },
            fail: function (err) {
              // console.log(err);
            }
          })
        } else {

        }
      },
      fail(error) {
        console.log(error + '错误');
      }
    })
  },
  globalData: {
    userInfo: null
  }
})